package com.sd.util;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

public class PreferencesManager {

	private final String PREFS_USER="ip_address";
	
	private String PREFS_NAME = "sd_xx";
	private static PreferencesManager instance;
	private SharedPreferences settings;
	private Editor sharedata;
	
	public static PreferencesManager getInstance(Context context){
		if(instance == null)
			instance = new PreferencesManager(context);
		return instance;
	}
	
	private PreferencesManager(Context context){
		settings = context.getSharedPreferences(PREFS_NAME, 0); 
		sharedata = settings.edit();
	}
	
	public void setUser(String user){
		sharedata.putString(PREFS_USER, user);
		sharedata.commit();
	}
	
	public String getUser(){
		return settings.getString(PREFS_NAME, "");
	}
	
	public void removeUser(){
		sharedata.remove(PREFS_USER);
		sharedata.commit();
	}
}
